{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Channel library\n",
    "\n",
    "This code to generate a sample channel library and stores it in the database `example.sqlite`. This channel library is used in the examples in this directory. See Auspex [example notebooks](https://github.com/BBN-Q/Auspex/tree/develop/doc/examples) for documentation. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from QGL import *\n",
    "\n",
    "cl = ChannelLibrary(db_resource_name=\"./example.sqlite\")\n",
    "q1 = cl.new_qubit(\"q1\")\n",
    "q2 = cl.new_qubit(\"q2\")\n",
    "CNOT12 = cl.new_edge(q1, q2)\n",
    "aps2_1 = cl.new_APS2(\"BBNAPS1\", address=\"192.168.5.101\") \n",
    "aps2_2 = cl.new_APS2(\"BBNAPS2\", address=\"192.168.5.102\")\n",
    "aps2_3 = cl.new_APS2(\"BBNAPS3\", address=\"192.168.5.103\") \n",
    "aps2_4 = cl.new_APS2(\"BBNAPS4\", address=\"192.168.5.104\")\n",
    "dig_1  = cl.new_X6(\"X6_1\", address=0)\n",
    "h1 = cl.new_source(\"Holz1\", \"HolzworthHS9000\", \"HS9004A-009-1\", power=-30)\n",
    "h2 = cl.new_source(\"Holz2\", \"HolzworthHS9000\", \"HS9004A-009-2\", power=-30) \n",
    "cl.set_control(q1, aps2_1, generator=h1)\n",
    "cl.set_measure(q1, aps2_2, dig_1.ch(1), generator=h2)\n",
    "cl.set_control(q2, aps2_3, generator=h1)\n",
    "cl.set_measure(q2, aps2_4, dig_1.ch(2), generator=h2)\n",
    "cl.set_master(aps2_1, aps2_1.ch(\"m2\"))\n",
    "cl.set_control(CNOT12, aps2_1, generator=h1)\n",
    "cl[\"q1\"].measure_chan.frequency = 0e6\n",
    "cl.commit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
